package com.roc.steelend.service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roc.steelend.mapper.SmallAccountMapper;
import com.roc.steelend.pojo.SmallAccount;
import com.roc.steelend.service.SmallAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class SmallAccountServiceImpl  implements SmallAccountService {


    @Autowired
    private SmallAccountMapper smallAccountMapper;

    @Override
    public List<HashMap<String, Object>> findSmallAccountData(Integer now, Integer size, Integer isPayTakeId, Integer bigAccountId) {

        now=(now-1)*size;

        return  smallAccountMapper.findSmallAccountData(now,size,isPayTakeId,bigAccountId) ;
    }

    @Override
    public Integer findSmallAccountDataCount(Integer isPayTakeId, Integer bigAccountId) {
        return smallAccountMapper.findSmallAccountDataCount(isPayTakeId,bigAccountId);
    }

    @Override
    public List<SmallAccount> findSmallAccountDataSpecial(Integer bigAccountId) {
        QueryWrapper<SmallAccount> wrapper = new QueryWrapper<>();
        if (bigAccountId!=null&&bigAccountId!=0){
            wrapper.eq("big_account_id",bigAccountId);
        }
        return  smallAccountMapper.selectList(wrapper);


    }

    @Override
    public List<SmallAccount> findSmallAccountDataSpecialTwo(Integer isPayTakeId) {
           return smallAccountMapper.findSmallAccountDataSpecialTwo(isPayTakeId);
    }
}
